package com.ji.controller;

import com.ji.pojo.Department;
import com.ji.pojo.Employee;
import com.ji.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@RestController
public class TestController2 {
    @Autowired
    private EmployeeService employeeService;
    @RequestMapping("/s1")
    public String t1(){
        employeeService.addEmployee (new Employee (1801,"季思朋","2315510122@qq.com",1,new Date (),new Department (101,"教学部")));
        return "ok";
    }
    @RequestMapping("/s2")
    public String t2(){
        employeeService.updateEmployee (new Employee (1801,"季","2315510122@qq.com",1,new Date (),new Department (101,"教学部")));
        return "ok";
    }
    @RequestMapping("/s3")
    public String t3(){
        employeeService.deleteEmployee (1801);
        return "ok";
    }
    @RequestMapping("/s4")
    public String t4(){
        System.out.println ("adsfadas");
        List<Employee> departments = employeeService.queryAllEmployee ();
        for (Employee department : departments) {
            System.out.println (department);
        }
        return "ok";
    }
    @RequestMapping("/s5")
    public String t5(){
        System.out.println ("adsfadas");
        Employee employee = employeeService.queryEmployee (1801);
        System.out.println (employee);

        return "ok";
    }
}
